﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows.Input;

using System.Windows;
using HAGISV2;

namespace HA.ModFlow.Application
{
    public static class GISCommands
    {

        static GISCommands()
        {
            extentToCurrent = new RoutedCommand();



            scatter2DSelect = new RoutedCommand();

            scatter2DAdd = new RoutedCommand();



            addVertex = new RoutedCommand();

            select = new RoutedCommand();

            clipShape = new RoutedCommand();

            zoomOut = new RoutedCommand();

            zoomIn = new RoutedCommand();

            extent = new RoutedCommand();

            pan = new RoutedCommand();

            move = new RoutedCommand();

            point = new RoutedCommand();

            line = new RoutedCommand();

            polyline = new RoutedCommand();

            polygon = new RoutedCommand();

            rotate = new RoutedCommand();

            scale = new RoutedCommand();

            allSelect = new RoutedCommand();

            endPointSelect = new RoutedCommand();

            nodeSelect = new RoutedCommand();

            lineSelect = new RoutedCommand();

            lineArraySelect = new RoutedCommand();

            planSelect = new RoutedCommand();

            union = new RoutedCommand();

            cross = new RoutedCommand();

            different = new RoutedCommand();

            ptSelectMv = new RoutedCommand();

            polySelectMv = new RoutedCommand();

            rowSelect = new RoutedCommand();

            colSelect = new RoutedCommand();

            addRow = new RoutedCommand();

            addCol = new RoutedCommand();

            moveLegend = new RoutedCommand();
        }

        #region

        static RoutedCommand moveLegend;

        public static RoutedCommand MoveLegend
        {
            get { return GISCommands.moveLegend; }
            set { GISCommands.moveLegend = value; }
        }


        static RoutedCommand extentToCurrent;

        public static RoutedCommand ExtentToCurrent
        {
            get { return GISCommands.extentToCurrent; }
            set { GISCommands.extentToCurrent = value; }
        }

        static RoutedCommand scatter2DSelect;

        public static RoutedCommand Scatter2DSelect
        {
            get { return GISCommands.scatter2DSelect; }
            set { GISCommands.scatter2DSelect = value; }
        }

        static RoutedCommand scatter2DAdd;

        public static RoutedCommand Scatter2DAdd
        {
            get { return GISCommands.scatter2DAdd; }
            set { GISCommands.scatter2DAdd = value; }
        }





        static RoutedCommand ptSelectMv;

        public static RoutedCommand PtSelectMv
        {
            get { return GISCommands.ptSelectMv; }
            set { GISCommands.ptSelectMv = value; }
        }
        static RoutedCommand polySelectMv;

        public static RoutedCommand PolySelectMv
        {
            get { return GISCommands.polySelectMv; }
            set { GISCommands.polySelectMv = value; }
        }
        static RoutedCommand rowSelect;

        public static RoutedCommand RowSelect
        {
            get { return GISCommands.rowSelect; }
            set { GISCommands.rowSelect = value; }
        }
        static RoutedCommand colSelect;

        public static RoutedCommand ColSelect
        {
            get { return GISCommands.colSelect; }
            set { GISCommands.colSelect = value; }
        }
        static RoutedCommand addRow;

        public static RoutedCommand AddRow
        {
            get { return GISCommands.addRow; }
            set { GISCommands.addRow = value; }
        }
        static RoutedCommand addCol;

        public static RoutedCommand AddCol
        {
            get { return GISCommands.addCol; }
            set { GISCommands.addCol = value; }
        }

        static RoutedCommand allSelect;

        public static RoutedCommand AllSelect
        {
            get { return GISCommands.allSelect; }
            set { GISCommands.allSelect = value; }
        }
        static RoutedCommand endPointSelect;

        public static RoutedCommand EndPointSelect
        {
            get { return GISCommands.endPointSelect; }
            set { GISCommands.endPointSelect = value; }
        }

        static RoutedCommand nodeSelect;

        public static RoutedCommand NodeSelect
        {
            get { return GISCommands.nodeSelect; }
            set { GISCommands.nodeSelect = value; }
        }

        static RoutedCommand lineSelect;

        public static RoutedCommand LineSelect
        {
            get { return GISCommands.lineSelect; }
            set { GISCommands.lineSelect = value; }
        }

        static RoutedCommand lineArraySelect;

        public static RoutedCommand LineArraySelect
        {
            get { return GISCommands.lineArraySelect; }
            set { GISCommands.lineArraySelect = value; }
        }

        static RoutedCommand addVertex;

        public static RoutedCommand AddVertex
        {
            get { return GISCommands.addVertex; }
            set { GISCommands.addVertex = value; }
        }


        static RoutedCommand planSelect;

        public static RoutedCommand PlanSelect
        {
            get { return GISCommands.planSelect; }
            set { GISCommands.planSelect = value; }
        }



        static RoutedCommand union;

        public static RoutedCommand Union
        {
            get { return GISCommands.union; }
            set { GISCommands.union = value; }
        }

        static RoutedCommand cross;

        public static RoutedCommand Cross
        {
            get { return GISCommands.cross; }
            set { GISCommands.cross = value; }
        }
        static RoutedCommand different;

        public static RoutedCommand Different
        {
            get { return GISCommands.different; }
            set { GISCommands.different = value; }
        }

        static RoutedCommand scale;

        public static RoutedCommand Scale
        {
            get { return GISCommands.scale; }
            set { GISCommands.scale = value; }
        }

        static RoutedCommand rotate;

        public static RoutedCommand Rotate
        {
            get { return GISCommands.rotate; }
            set { GISCommands.rotate = value; }
        }


        static RoutedCommand polyline;

        public static RoutedCommand Polyline
        {
            get { return GISCommands.polyline; }
            set { GISCommands.polyline = value; }
        }

        static RoutedCommand polygon;

        public static RoutedCommand Polygon
        {
            get { return GISCommands.polygon; }
            set { GISCommands.polygon = value; }
        }

        static RoutedCommand line;

        public static RoutedCommand Line
        {
            get { return GISCommands.line; }
            set { GISCommands.line = value; }
        }


        static RoutedCommand point;

        public static RoutedCommand Point
        {
            get { return GISCommands.point; }
            set { GISCommands.point = value; }
        }

        static RoutedCommand extent;

        public static RoutedCommand Extent
        {
            get { return GISCommands.extent; }
            set { GISCommands.extent = value; }
        }


        static RoutedCommand select;

        public static RoutedCommand Select
        {
            get { return GISCommands.select; }
            set { GISCommands.select = value; }
        }


        //基础视图部分

        static RoutedCommand zoomOut;

        public static RoutedCommand ZoomOut
        {
            get { return GISCommands.zoomOut; }

        }




        static RoutedCommand zoomIn;

        public static RoutedCommand ZoomIn
        {
            get { return GISCommands.zoomIn; }

        }


        static RoutedCommand pan;

        public static RoutedCommand Pan
        {
            get { return GISCommands.pan; }
            set { GISCommands.pan = value; }
        }

        static RoutedCommand move;

        public static RoutedCommand Move
        {
            get { return GISCommands.move; }
            set { GISCommands.move = value; }
        }



        static RoutedCommand clipShape;

        public static RoutedCommand ClipShape
        {
            get { return GISCommands.clipShape; }
            set { GISCommands.clipShape = value; }
        }

        #region 位图相关操作
        static RoutedCommand editImage = new RoutedCommand();
        /// <summary>
        /// 编辑位图
        /// </summary>
        public static RoutedCommand EditImage
        {
            get { return GISCommands.editImage; }
            set { GISCommands.editImage = value; }
        }

        static RoutedCommand delImage = new RoutedCommand();
        /// <summary>
        /// 删除位图
        /// </summary>
        public static RoutedCommand DelImage
        {
            get { return GISCommands.delImage; }
            set { GISCommands.delImage = value; }
        }


        #endregion


        //gms选择工具


        #endregion

        public static void BindCommandsToWindow(Window window)
        {
            //绑定树形右键菜单命令
            CommandBinding cbExtentToCurrent = new CommandBinding();
            cbExtentToCurrent.Command = extentToCurrent;
            cbExtentToCurrent.CanExecute+=new CanExecuteRoutedEventHandler(cbExtentToCurrent_CanExecute);
            cbExtentToCurrent.Executed+=new ExecutedRoutedEventHandler(cbExtentToCurrent_Executed);
            window.CommandBindings.Add(cbExtentToCurrent);

            //绑定Scatter2D操作命令
            CommandBinding cbScatter2DSelect = new CommandBinding();
            cbScatter2DSelect.Command = scatter2DSelect;
            cbScatter2DSelect.CanExecute +=new CanExecuteRoutedEventHandler(cbScatter2DSelect_CanExecute);
            cbScatter2DSelect.Executed +=new ExecutedRoutedEventHandler(cbScatter2DSelect_Executed);
            window.CommandBindings.Add(cbScatter2DSelect);

            CommandBinding cbScatter2DAdd = new CommandBinding();
            cbScatter2DAdd.Command = scatter2DAdd;
            cbScatter2DAdd.CanExecute +=new CanExecuteRoutedEventHandler(cbScatter2DAdd_CanExecute);
            cbScatter2DAdd.Executed +=new ExecutedRoutedEventHandler(cbScatter2DAdd_Executed);
            window.CommandBindings.Add(cbScatter2DAdd);



            //绑定NewProject命令
            CommandBinding cbSelect = new CommandBinding();
            cbSelect.Command = select;
            cbSelect.CanExecute += new CanExecuteRoutedEventHandler(cbSelect_CanExecute);
            cbSelect.Executed += new ExecutedRoutedEventHandler(cbSelect_Executed);
            window.CommandBindings.Add(cbSelect);


            CommandBinding cbZoomIn = new CommandBinding();
            cbZoomIn.Command = zoomIn;
            cbZoomIn.CanExecute += new CanExecuteRoutedEventHandler(cbZoomIn_CanExecute);
            cbZoomIn.Executed += new ExecutedRoutedEventHandler(cbZoomIn_Executed);
            window.CommandBindings.Add(cbZoomIn);

            CommandBinding cbClipShape = new CommandBinding();
            cbClipShape.Command = clipShape;
            cbClipShape.CanExecute += new CanExecuteRoutedEventHandler(cbClipShape_CanExecute);
            cbClipShape.Executed += new ExecutedRoutedEventHandler(cbClipShape_Executed);
            window.CommandBindings.Add(cbClipShape);

            CommandBinding cbZoomOut = new CommandBinding();
            cbZoomOut.Command = zoomOut;
            cbZoomOut.CanExecute += new CanExecuteRoutedEventHandler(cbZoomOut_CanExecute);
            cbZoomOut.Executed += new ExecutedRoutedEventHandler(cbZoomOut_Executed);
            window.CommandBindings.Add(cbZoomOut);

            CommandBinding cbExtent = new CommandBinding();
            cbExtent.Command = extent;
            cbExtent.CanExecute += new CanExecuteRoutedEventHandler(cbExtent_CanExecute);
            cbExtent.Executed += new ExecutedRoutedEventHandler(cbExtent_Executed);
            window.CommandBindings.Add(cbExtent);

            CommandBinding cbPan = new CommandBinding();
            cbPan.Command = pan;
            cbPan.CanExecute += new CanExecuteRoutedEventHandler(cbPan_CanExecute);
            cbPan.Executed += new ExecutedRoutedEventHandler(cbPan_Executed);
            window.CommandBindings.Add(cbPan);

            CommandBinding cbMove = new CommandBinding();
            cbMove.Command = move;
            cbMove.CanExecute += new CanExecuteRoutedEventHandler(cbMove_CanExecute);
            cbMove.Executed += new ExecutedRoutedEventHandler(cbMove_Executed);
            window.CommandBindings.Add(cbMove);

            CommandBinding cbMoveLegend = new CommandBinding();
            cbMoveLegend.Command = moveLegend;
            cbMoveLegend.CanExecute+=new CanExecuteRoutedEventHandler(cbMoveLegend_CanExecute);
            cbMoveLegend.Executed+=new ExecutedRoutedEventHandler(cbMoveLegend_Executed);
            window.CommandBindings.Add(cbMoveLegend);

            CommandBinding cbPoint = new CommandBinding();
            cbPoint.Command = point;
            cbPoint.CanExecute += new CanExecuteRoutedEventHandler(cbPoint_CanExecute);
            cbPoint.Executed += new ExecutedRoutedEventHandler(cbPoint_Executed);
            window.CommandBindings.Add(cbPoint);

            CommandBinding cbLine = new CommandBinding();
            cbLine.Command = line;
            cbLine.CanExecute += new CanExecuteRoutedEventHandler(cbLine_CanExecute);
            cbLine.Executed += new ExecutedRoutedEventHandler(cbLine_Executed);
            window.CommandBindings.Add(cbLine);


            CommandBinding cbPolyline = new CommandBinding();
            cbPolyline.Command = polyline;
            cbPolyline.CanExecute += new CanExecuteRoutedEventHandler(cbPolyline_CanExecute);
            cbPolyline.Executed += new ExecutedRoutedEventHandler(cbPolyline_Executed);
            window.CommandBindings.Add(cbPolyline);


            CommandBinding cbPolygon = new CommandBinding();
            cbPolygon.Command = polygon;
            cbPolygon.CanExecute += new CanExecuteRoutedEventHandler(cbPolygon_CanExecute);
            cbPolygon.Executed += new ExecutedRoutedEventHandler(cbPolygon_Executed);
            window.CommandBindings.Add(cbPolygon);


            CommandBinding cbRotate = new CommandBinding();
            cbRotate.Command = rotate;
            cbRotate.CanExecute += new CanExecuteRoutedEventHandler(cbRotate_CanExecute);
            cbRotate.Executed += new ExecutedRoutedEventHandler(cbRotate_Executed);
            window.CommandBindings.Add(cbRotate);


            CommandBinding cbScale = new CommandBinding();
            cbScale.Command = scale;
            cbScale.CanExecute += new CanExecuteRoutedEventHandler(cbScale_CanExecute);
            cbScale.Executed += new ExecutedRoutedEventHandler(cbScale_Executed);
            window.CommandBindings.Add(cbScale);

            //全部选择
            CommandBinding cbAllSelect = new CommandBinding();
            cbAllSelect.Command = allSelect;
            cbAllSelect.CanExecute += new CanExecuteRoutedEventHandler(cbAllSelect_CanExecute);
            cbAllSelect.Executed += new ExecutedRoutedEventHandler(cbAllSelect_Executed);
            window.CommandBindings.Add(cbAllSelect);

            //端点选择
            CommandBinding cbEndPointSelect = new CommandBinding();
            cbEndPointSelect.Command = endPointSelect;
            cbEndPointSelect.CanExecute += new CanExecuteRoutedEventHandler(cbEndPointSelect_CanExecute);
            cbEndPointSelect.Executed += new ExecutedRoutedEventHandler(cbEndPointSelect_Executed);
            window.CommandBindings.Add(cbEndPointSelect);

            //节点选择
            CommandBinding cbNodeSelect = new CommandBinding();
            cbNodeSelect.Command = nodeSelect;
            cbNodeSelect.CanExecute += new CanExecuteRoutedEventHandler(cbNodeSelect_CanExecute);
            cbNodeSelect.Executed += new ExecutedRoutedEventHandler(cbNodeSelect_Executed);
            window.CommandBindings.Add(cbNodeSelect);

            //线选择
            CommandBinding cbLineSelect = new CommandBinding();
            cbLineSelect.Command = lineSelect;
            cbLineSelect.CanExecute += new CanExecuteRoutedEventHandler(cbLineSelect_CanExecute);
            cbLineSelect.Executed += new ExecutedRoutedEventHandler(cbLineSelect_Executed);
            window.CommandBindings.Add(cbLineSelect);


            //线组选择
            CommandBinding cbLineArraySelect = new CommandBinding();
            cbLineArraySelect.Command = lineArraySelect;
            cbLineArraySelect.CanExecute += new CanExecuteRoutedEventHandler(cbLineArraySelect_CanExecute);
            cbLineArraySelect.Executed += new ExecutedRoutedEventHandler(cbLineArraySelect_Executed);
            window.CommandBindings.Add(cbLineArraySelect);

            //面选择
            CommandBinding cbPlanSelect = new CommandBinding();
            cbPlanSelect.Command = planSelect;
            cbPlanSelect.CanExecute += new CanExecuteRoutedEventHandler(cbPlanSelect_CanExecute);
            cbPlanSelect.Executed += new ExecutedRoutedEventHandler(cbPlanSelect_Executed);
            window.CommandBindings.Add(cbPlanSelect);

            //添加节点
            CommandBinding cbAddVertex = new CommandBinding();
            cbAddVertex.Command = addVertex;
            cbAddVertex.CanExecute+=new CanExecuteRoutedEventHandler(cbAddVertex_CanExecute);
            cbAddVertex.Executed+=new ExecutedRoutedEventHandler(cbAddVertex_Executed);
            window.CommandBindings.Add(cbAddVertex);

            //合并
            CommandBinding cbUnion = new CommandBinding();
            cbUnion.Command = union;
            cbUnion.CanExecute += new CanExecuteRoutedEventHandler(cbUnion_CanExecute);
            cbUnion.Executed += new ExecutedRoutedEventHandler(cbUnion_Executed);
            window.CommandBindings.Add(cbUnion);


            CommandBinding cbCross = new CommandBinding();
            cbCross.Command = cross;
            cbCross.CanExecute += new CanExecuteRoutedEventHandler(cbCross_CanExecute);
            cbCross.Executed += new ExecutedRoutedEventHandler(cbCross_Executed);
            window.CommandBindings.Add(cbCross);


            CommandBinding cbDifferent = new CommandBinding();
            cbDifferent.Command = different;
            cbDifferent.CanExecute += new CanExecuteRoutedEventHandler(cbDifferent_CanExecute);
            cbDifferent.Executed += new ExecutedRoutedEventHandler(cbDifferent_Executed);
            window.CommandBindings.Add(cbDifferent);


            CommandBinding cbPtSelectMv = new CommandBinding();
            cbPtSelectMv.Command = ptSelectMv;
            cbPtSelectMv.CanExecute += new CanExecuteRoutedEventHandler(cbPtSelectMv_CanExecute);
            cbPtSelectMv.Executed += new ExecutedRoutedEventHandler(cbPtSelectMv_Executed);
            window.CommandBindings.Add(cbPtSelectMv);


            CommandBinding cbPolySelectMv = new CommandBinding();
            cbPolySelectMv.Command = polySelectMv;
            cbPolySelectMv.CanExecute += new CanExecuteRoutedEventHandler(cbPolySelectMv_CanExecute);
            cbPolySelectMv.Executed += new ExecutedRoutedEventHandler(cbPolySelectMv_Executed);
            window.CommandBindings.Add(cbPolySelectMv);


            CommandBinding cbRowSelect = new CommandBinding();
            cbRowSelect.Command = rowSelect;
            cbRowSelect.CanExecute += new CanExecuteRoutedEventHandler(cbRowSelect_CanExecute);
            cbRowSelect.Executed += new ExecutedRoutedEventHandler(cbRowSelect_Executed);
            window.CommandBindings.Add(cbRowSelect);


            CommandBinding cbColSelect = new CommandBinding();
            cbColSelect.Command = colSelect;
            cbColSelect.CanExecute += new CanExecuteRoutedEventHandler(cbColSelect_CanExecute);
            cbColSelect.Executed += new ExecutedRoutedEventHandler(cbColSelect_Executed);
            window.CommandBindings.Add(cbColSelect);


            CommandBinding cbAddRow = new CommandBinding();
            cbAddRow.Command = addRow;
            cbAddRow.CanExecute += new CanExecuteRoutedEventHandler(cbAddRow_CanExecute);
            cbAddRow.Executed += new ExecutedRoutedEventHandler(cbAddRow_Executed);
            window.CommandBindings.Add(cbAddRow);


            CommandBinding cbAddCol = new CommandBinding();
            cbAddCol.Command = addCol;
            cbAddCol.CanExecute += new CanExecuteRoutedEventHandler(cbAddCol_CanExecute);
            cbAddCol.Executed += new ExecutedRoutedEventHandler(cbAddCol_Executed);
            window.CommandBindings.Add(cbAddCol);

            //右键编辑位图
            CommandBinding cbEditImage = new CommandBinding();
            cbEditImage.Command = editImage;
            cbEditImage.Executed += new ExecutedRoutedEventHandler(cbEditImage_Executed);
            cbEditImage.CanExecute += new CanExecuteRoutedEventHandler(cbEditImage_CanExecute);
            window.CommandBindings.Add(cbEditImage);

            //右键删除位图
            CommandBinding cbDelImage = new CommandBinding();
            cbDelImage.Command = delImage;
            cbDelImage.Executed += new ExecutedRoutedEventHandler(cbDelImage_Executed);
            cbDelImage.CanExecute += new CanExecuteRoutedEventHandler(cbDelImage_CanExecute);
            window.CommandBindings.Add(cbDelImage);
        }

        static void cbMoveLegend_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbMoveLegend_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.MOVELEGEND,GisModule.DefaultModule.IsolineLayerId);
        }


        static void cbDelImage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }

        static void cbDelImage_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Data.BitImageInfoes value = (Data.BitImageInfoes)e.Parameter;
            foreach (KeyValuePair<string,Data.BitImageInfoes> item in ProjectService.DefaultService.Project.AssistData.BitImageIdAndInfoes)
            {
                if (item.Value.Id == value.Id)
                {
                    ProjectService.DefaultService.Project.AssistData.RemoveBitImage(item.Key);
                    
                    break;
                }
            }
        }

        static void cbEditImage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }

        static void cbEditImage_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            //调用位图编辑功能窗体
            DataOperationModule.DefaultModule.ImportFile(ImportFileType.BITMAP);
        }
        #region

        static void cbExtentToCurrent_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            //e的Parameter携带的为Layer的id
            GisModule.DefaultModule.GisManager.ZoomToCurrentLayer((string)e.Parameter);
        }

        static void cbExtentToCurrent_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }



        static void cbScatter2DSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.SCATTER2DSELECT);
        }

        static void cbScatter2DSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbScatter2DAdd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.SCATTER2DADD);
        }

        static void cbScatter2DAdd_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }



        static void cbAllSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.ALLSELECT);
        }

        static void cbAllSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbEndPointSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.NODESELECT);
        }

        static void cbEndPointSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbNodeSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.VERTEXSELECT);
        }

        static void cbNodeSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbLineSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.LINESELECT);
        }

        static void cbLineSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbLineArraySelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.LINEARRAYSELECT);
        }

        static void cbLineArraySelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbPlanSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.PLANSELECT);
        }

        static void cbPlanSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbAddVertex_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.ADDVERTEX);
        }

        static void cbAddVertex_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }



        static void cbUnion_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void cbUnion_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbCross_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void cbCross_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbDifferent_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            //throw new NotImplementedException();
        }

        static void cbDifferent_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbPtSelectMv_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            if (ProjectService.DefaultService.Project.Grid3dData.MainGrid != null)
            {

                string name = GisModule.DefaultModule.GridLayerId;

                GisModule.DefaultModule.SetCurrentLayer(name);

                //GisModule.DefaultModule.GisManager.InteractiveSystem.CurrentLayer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());



            }

            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.GRIDPOINT);
        }

        static void cbPtSelectMv_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }



        //网格修改部分


        static void cbPolySelectMv_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            if (ProjectService.DefaultService.Project.Grid3dData.MainGrid != null)
            {

                string name = GisModule.DefaultModule.GridLayerId;

                GisModule.DefaultModule.SetCurrentLayer(name);

                //GisModule.DefaultModule.GisManager.InteractiveSystem.CurrentLayer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());



            }

            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.GRIDCELL);
        }

        static void cbPolySelectMv_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbRowSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            if (ProjectService.DefaultService.Project.Grid3dData.MainGrid != null)
            {

                string name = GisModule.DefaultModule.GridLayerId;

                GisModule.DefaultModule.SetCurrentLayer(name);

                //GisModule.DefaultModule.GisManager.InteractiveSystem.CurrentLayer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());



            }
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.GRIDROW);
        }

        static void cbRowSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbColSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (ProjectService.DefaultService.Project.Grid3dData.MainGrid != null)
            {

                string name = GisModule.DefaultModule.GridLayerId;

                GisModule.DefaultModule.SetCurrentLayer(name);

                //GisModule.DefaultModule.GisManager.InteractiveSystem.CurrentLayer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());



            }

            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.GRIDCOL);
        }

        static void cbColSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbAddRow_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (ProjectService.DefaultService.Project.Grid3dData.MainGrid != null)
            {

                string name = GisModule.DefaultModule.GridLayerId;

                GisModule.DefaultModule.SetCurrentLayer(name);

                //GisModule.DefaultModule.GisManager.InteractiveSystem.CurrentLayer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());



            }

            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.GRIDADDROW);
        }

        static void cbAddRow_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbAddCol_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            if (ProjectService.DefaultService.Project.Grid3dData.MainGrid != null)
            {

                string name = GisModule.DefaultModule.GridLayerId;

                GisModule.DefaultModule.SetCurrentLayer(name);

                //GisModule.DefaultModule.GisManager.InteractiveSystem.CurrentLayer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());



            }
            GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(MAPMODE.GRIDADDCOL);
        }

        static void cbAddCol_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbScale_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void cbScale_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbRotate_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void cbRotate_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbPolygon_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.ADDPOLYGON);
        }

        static void cbPolygon_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbPolyline_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.ADDPOLYLINE);
        }

        static void cbPolyline_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbLine_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.ADDLINE);
        }

        static void cbLine_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbPoint_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.ADDPOINT);
        }

        static void cbPoint_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbMove_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void cbMove_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }



        static void cbPan_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.PAN);
        }

        static void cbPan_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        static void cbExtent_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.ZoomToExtent();
        }

        static void cbExtent_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }


        static void cbZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.ZOOMOUT);
        }

        static void cbZoomOut_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }


        static void cbClipShape_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.CLIPPOLY);
        }

        static void cbClipShape_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }




        static void cbZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.ZOOMIN);
        }

        static void cbZoomIn_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }




        static void cbSelect_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            GisModule.DefaultModule.GisManager.SetMapMode(MAPMODE.SELECT);
        }

        static void cbSelect_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !ProjectService.DefaultService.BNullProj;
        }

        #endregion

    }
}
